import 'dart:math';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/page/task/main/task/models/question.dart';
import 'package:leader_help/utils/util.dart';

import '../controller.dart';

class GrapQuestionCell extends GetView<GrapQuestionController> {
  const GrapQuestionCell({Key? key, required this.mod}) : super(key: key);
  final QuestionModel mod;
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 10.r),
      child: ClipRRect(
        borderRadius: BorderRadius.circular(6.r),
        child: Container(
          color: Colors.white,
          child: Stack(
            children: [
              Row(
                children: [
                  Container(
                    height: 100.r,
                    width: 60.r,
                    margin: EdgeInsets.all(10.r),
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                      color: const Color(0xffEA6054),
                      borderRadius: BorderRadius.circular(3.r),
                    ),
                    child: Text(
                      '问题\n现象',
                      textAlign: TextAlign.center,
                      style:
                          pfMediumStyle(color: Colors.white, fontSize: 15.sp),
                    ),
                  ),
                  Expanded(
                    child: SizedBox(
                      height: 100.r,
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                        children: [
                          Row(
                            children: [
                              Text(
                                mod.title,
                                style: pfSCStyle(
                                    color: ColorsUtil.title, fontSize: 15.sp),
                              ),
                              mod.iden == null
                                  ? const SizedBox()
                                  : Container(
                                      alignment: Alignment.center,
                                      padding: const EdgeInsets.all(1),
                                      margin: EdgeInsets.only(left: 5.r),
                                      decoration: BoxDecoration(
                                        border: Border.all(
                                            color: ColorsUtil.red, width: 1),
                                      ),
                                      child: Text(
                                        mod.iden!,
                                        style: pfMediumStyle(
                                            color: ColorsUtil.title,
                                            fontSize: 13.sp),
                                      ),
                                    ),
                            ],
                          ),
                          Row(
                            children: [
                              Container(
                                color: ColorsUtil.bg,
                                padding: EdgeInsets.symmetric(
                                    horizontal: 3.r, vertical: 2.r),
                                child: Text(
                                  mod.typeName,
                                  style: pfMediumStyle(
                                      color: ColorsUtil.subTitle,
                                      fontSize: 12.sp),
                                ),
                              ),
                              SizedBox(
                                width: 10.r,
                              ),
                              mod.type == null
                                  ? const SizedBox()
                                  : Container(
                                      color: ColorsUtil.pink,
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 3.r, vertical: 2.r),
                                      child: Text(
                                        mod.type!,
                                        style: pfMediumStyle(
                                            color: ColorsUtil.red,
                                            fontSize: 12.sp),
                                      ),
                                    )
                            ],
                          ),
                          Row(
                            children: [
                              Icon(
                                Icons.info,
                                color: ColorsUtil.orange,
                                size: 18.r,
                              ),
                              Text(
                                '需要定方案作安排',
                                style: pfMediumStyle(
                                    color: ColorsUtil.orange, fontSize: 14.sp),
                              ),
                              SizedBox(
                                width: 20.r,
                              ),
                              InkWell(
                                onTap: () => controller.actionToDetail(mod),
                                child: Container(
                                  height: 24.r,
                                  alignment: Alignment.center,
                                  padding:
                                      EdgeInsets.symmetric(horizontal: 10.r),
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.circular(12.r),
                                    border: Border.all(
                                        color: ColorsUtil.red, width: 1),
                                  ),
                                  child: Text(
                                    '前往定方案',
                                    style: pfMediumStyle(
                                        color: ColorsUtil.title,
                                        fontSize: 13.sp),
                                  ),
                                ),
                              )
                            ],
                          )
                        ],
                      ),
                    ),
                  ),
                ],
              ),
              Positioned(
                right: 0,
                child: Visibility(
                  visible: mod.level == 1,
                  child: Transform(
                    transform: Matrix4.rotationZ(pi / 4),
                    origin: Offset(80.r, 50.r),
                    child: Container(
                      color: const Color(0xff00C9B0),
                      width: 60.r,
                      height: 60.r,
                      alignment: Alignment.bottomCenter,
                      child: Text(
                        '重点',
                        style:
                            pfMediumStyle(color: Colors.white, fontSize: 12.sp),
                      ),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
